package com.fot.executor;

import java.util.concurrent.*;

/**
 * 线程池工厂
 */
public class ExecutorFactory {
    public static ExecutorService newSingleExecutorService(final ThreadFactory threadFactory) {
        return Executors.newFixedThreadPool(1, threadFactory);
    }
    public static ThreadPoolExecutor newCustomerThreadExecutor(final int coreThreads,
                                                               final int maxThreads,
                                                               final long keepAliveTimeMs,
                                                               final int queueSize,
                                                               final ThreadFactory threadFactory) {
        return new ThreadPoolExecutor(coreThreads, maxThreads, keepAliveTimeMs,
                TimeUnit.MICROSECONDS, new ArrayBlockingQueue<>(queueSize),
                threadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
    }


}
